#include "HeadFiles.h"

Object::Object()
{
	this->pos = {0,0};
	this->left_distance = 1;
	this->up_distance = 1;
	this->aftpos = { 0,0 };
	this->bump = false;
}

Object::Object(COORD pos)
{
	this->pos = pos;
	this->left_distance = 1;
	this->up_distance = 1;
}

Object::Object(COORD pos, unsigned up_distance = 2, unsigned left_distance = 2)
{
	this->pos = pos;
	this->left_distance = left_distance;
	this->up_distance = up_distance;
	this->aftpos = { 0,0 };
	this->bump = false;
}


COORD* Object::ReturnPos()
{
	return &this->pos;
}

void Object::SetBorderUD(unsigned up_distance)
{
	this->up_distance = up_distance;
}

void Object::SetBorderLD(unsigned letf_distance)
{
	this->letf_distance = letf_distance;
}

unsigned Object::ReturnBorderUD()
{
	return up_distance;
}

unsigned Object::ReturnBorderLD()
{
	return letf_distance;
}

bool Object::IsCollided(Object* object)
{
	if (object!=nullptr)
	{
		unsigned sub_x = abs(object->ReturnPos()->X - this->pos.X);
		unsigned sub_y = abs(object->ReturnPos()->Y - this->pos.Y);
		if (sub_x > 2 || sub_y > 2)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
		return false;
}

bool Object::IsNextCollided(Object* object)
{
	if (object)
	{
		unsigned sub_x = abs(object->ReturnPos()->X - this->aftpos.X);
		unsigned sub_y = abs(object->ReturnPos()->Y - this->aftpos.Y);
		if (sub_x > 2 || sub_y > 2)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
		return false;
}

void Object::SetBump(bool flag)
{
	bump = flag;
}

bool Object::ReturnBump()
{
	return bump;
}

Object * Object::ReturnThis()
{
	return this;
}
